package com.sam.im.sms.db;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

/**
 * 描述
 * liuyucheng
 * Created By 刘育成 on 2019/6/10.
 */
public class DBOpenHelper extends SQLiteOpenHelper {
    private final static String TAG = "DBOpenHelper";
    private final static String DATABASE_NAME = "intercept.db";
    public final static String DATABASE_STUDENT_TABLE_NAME = "intercept";
    private final static int DATABASE_VERSION = 1;

    private Context mContext;

    private final static String CREATE_STUDENT_TABLE = "CREATE TABLE "
            + DATABASE_STUDENT_TABLE_NAME
            + "(id INTEGER PRIMARY KEY AUTOINCREMENT, "
            + "address TEXT NOT NULL, "
            + "type TEXT NOT NULL, "
            + "read TEXT NOT NULL, "
            + "body TEXT NOT NULL, "
            + "date TEXT NOT NULL);";

    public DBOpenHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        mContext = context;
    }
    public DBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, DATABASE_NAME, factory, DATABASE_VERSION);
        mContext = context;
    }
    public DBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
        super(context, DATABASE_NAME, factory, DATABASE_VERSION, errorHandler);
        mContext = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_STUDENT_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.d(TAG, "onUpgrade o = " + oldVersion + " , n = " + newVersion);
//        onCreate(db);
    }

}
